import { jsxs as u, jsx as e, Fragment as b } from "react/jsx-runtime";
import { useState as y, useEffect as C, useRef as k } from "react";
import S from "react-dom";
const N = (i) => {
  const {
    type: n = "primary",
    shape: t = "normal",
    size: s = "primary",
    className: o,
    children: l,
    prefix: c,
    suffix: d,
    onClick: r
  } = i;
  return /* @__PURE__ */ u(
    "div",
    {
      className: `hs-ui-button hs-ui-button-${n} hs-ui-button-shape-${t} hs-ui-button-size-${s} ${o}`,
      onClick: r,
      children: [
        /* @__PURE__ */ e("div", { className: "hs-ui-button__prefix", children: c }),
        /* @__PURE__ */ e("div", { className: "hs-ui-button__wrapper", children: /* @__PURE__ */ e("button", { className: " hs-ui-button__button", children: l }) }),
        /* @__PURE__ */ e("div", { className: "hs-ui-button__suffix", children: d })
      ]
    }
  );
}, D = (i) => {
  const {
    value: n,
    placeholder: t,
    type: s,
    shape: o,
    prefix: l,
    suffix: c,
    className: d,
    shadowLayout: r = "inset",
    disabled: m,
    readOnly: p,
    onChange: _,
    onClickPrefix: v,
    onClickSuffix: h
  } = i;
  return /* @__PURE__ */ u(
    "div",
    {
      className: `hs-ui-input ${d ?? ""} hs-ui-input-shape-${o ?? "primary"} hs-ui-input-shadow-${r} ${m || p ? "hs-ui-input-disabled" : ""}`,
      children: [
        /* @__PURE__ */ e(
          "div",
          {
            className: "hs-ui-input__prefix",
            onClick: v ?? (() => {
            }),
            children: l
          }
        ),
        /* @__PURE__ */ e("div", { className: "hs-ui-input__wrapper", children: /* @__PURE__ */ e(
          "input",
          {
            className: " hs-ui-input__inner",
            type: s ?? "text",
            placeholder: t ?? "PLEASE INPUT",
            value: n ?? "",
            onChange: _ ?? (() => {
            }),
            disabled: m,
            readOnly: p
          }
        ) }),
        /* @__PURE__ */ e(
          "div",
          {
            className: "hs-ui-input__suffix",
            onClick: h ?? (() => {
            }),
            children: c
          }
        )
      ]
    }
  );
}, ne = (i) => {
  const { className: n, children: t } = i;
  return /* @__PURE__ */ e("div", { className: `hs-ui-container ${n}`, children: t });
}, T = (i) => {
  const { className: n = "", children: t, action: s = "" } = i;
  return /* @__PURE__ */ e(
    "form",
    {
      className: `hs-ui-form ${n}`,
      action: s,
      children: t
    }
  );
}, V = (i) => {
  const { children: n, label: t = "" } = i, [s, o] = y(!0);
  return C(() => {
    t ?? o(!1);
  }, []), /* @__PURE__ */ u("div", { className: "hs-ui-form-item", children: [
    s && /* @__PURE__ */ e("div", { className: "hs-ui-form-item__label", children: t }),
    /* @__PURE__ */ e("div", { children: n })
  ] });
}, H = T;
H.Item = V;
const F = () => /* @__PURE__ */ u(
  "svg",
  {
    viewBox: "0 0 1024 1024",
    version: "1.1",
    xmlns: "http://www.w3.org/2000/svg",
    "p-id": "15340",
    width: "16",
    height: "16",
    children: [
      /* @__PURE__ */ e(
        "path",
        {
          d: "M705.6 124.9c-5.3-2.7-11.6 1.2-11.6 7.2v64.2c0 5.5 2.9 10.6 7.5 13.6 22.4 14.1 43.2 30.7 62.2 49.8 32.7 32.8 58.4 70.9 76.3 113.3 18.5 43.9 27.9 90.5 27.9 138.7 0 48.1-9.4 94.8-27.9 138.7-17.9 42.4-43.6 80.5-76.3 113.3-32.7 32.8-70.8 58.5-113.2 76.4-43.8 18.6-90.5 28-138.5 28s-94.7-9.4-138.5-28c-42.4-17.9-80.5-43.6-113.2-76.4-32.7-32.8-58.4-70.9-76.3-113.3-18.5-43.9-27.9-90.5-27.9-138.7 0-48.1 9.4-94.8 27.9-138.7 17.9-42.4 43.6-80.5 76.3-113.3 19-19 39.8-35.6 62.2-49.8 4.7-2.9 7.5-8.1 7.5-13.6V132c0-6-6.3-9.8-11.6-7.2C178.5 195.2 82 339.3 80 506.3 77.2 745.1 272.5 943.5 511.2 944c239 0.5 432.8-193.3 432.8-432.4 0-169.2-97-315.7-238.4-386.7z",
          "p-id": "15341",
          fill: "#696868"
        }
      ),
      /* @__PURE__ */ e(
        "path",
        {
          d: "M480 560h64c4.4 0 8-3.6 8-8V88c0-4.4-3.6-8-8-8h-64c-4.4 0-8 3.6-8 8v464c0 4.4 3.6 8 8 8z",
          "p-id": "15342",
          fill: "#696868"
        }
      )
    ]
  }
), X = () => /* @__PURE__ */ e(
  "svg",
  {
    className: "hs-ui-icon hs-ui-icon_right",
    viewBox: "0 0 1024 1024",
    version: "1.1",
    xmlns: "http://www.w3.org/2000/svg",
    "p-id": "8856",
    id: "mx_n_1721901148669",
    width: "16",
    height: "16",
    children: /* @__PURE__ */ e(
      "path",
      {
        d: "M765.7 486.8L314.9 134.7c-5.3-4.1-12.9-0.4-12.9 6.3v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1c16.4-12.8 16.4-37.6 0-50.4z",
        "p-id": "8857",
        fill: "#696868"
      }
    )
  }
), j = () => /* @__PURE__ */ e(
  "svg",
  {
    className: "hs-ui-icon hs-ui-icon_left",
    viewBox: "0 0 1024 1024",
    version: "1.1",
    xmlns: "http://www.w3.org/2000/svg",
    "p-id": "8993",
    width: "16",
    height: "16",
    children: /* @__PURE__ */ e(
      "path",
      {
        d: "M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8c-16.4 12.8-16.4 37.5 0 50.3l450.8 352.1c5.3 4.1 12.9 0.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z",
        "p-id": "8994",
        fill: "#696868"
      }
    )
  }
), R = () => /* @__PURE__ */ u(
  "svg",
  {
    className: "hs-ui-icon hs-ui-icon_upload",
    viewBox: "0 0 1024 1024",
    version: "1.1",
    xmlns: "http://www.w3.org/2000/svg",
    "p-id": "9297",
    id: "mx_n_1721901595864",
    width: "16",
    height: "16",
    children: [
      /* @__PURE__ */ e(
        "path",
        {
          d: "M400 317.7h73.9V656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V317.7H624c6.7 0 10.4-7.7 6.3-12.9L518.3 163c-3.2-4.1-9.4-4.1-12.6 0l-112 141.7c-4.1 5.3-0.4 13 6.3 13z",
          "p-id": "9298",
          fill: "#696868"
        }
      ),
      /* @__PURE__ */ e(
        "path",
        {
          d: "M878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z",
          "p-id": "9299",
          fill: "#696868"
        }
      )
    ]
  }
), W = () => /* @__PURE__ */ e(
  "svg",
  {
    className: "hs-ui-icon hs-ui-icon_search",
    viewBox: "0 0 1024 1024",
    version: "1.1",
    xmlns: "http://www.w3.org/2000/svg",
    "p-id": "8693",
    width: "16",
    height: "16",
    children: /* @__PURE__ */ e(
      "path",
      {
        d: "M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6c3.2 3.2 8.4 3.2 11.6 0l43.6-43.5c3.2-3.2 3.2-8.4 0-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z",
        fill: "#696868",
        "p-id": "8694"
      }
    )
  }
), B = () => /* @__PURE__ */ e("svg", { className: "hs-ui-icon hs-ui-icon_close", viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", "p-id": "8814", id: "mx_n_1722218858574", width: "16", height: "16", children: /* @__PURE__ */ e("path", { d: "M563.8 512l262.5-312.9c4.4-5.2 0.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9c-4.4 5.2-0.7 13.1 6.1 13.1h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z", "p-id": "8815", fill: "#696868" }) }), z = () => /* @__PURE__ */ e("svg", { className: "hs-ui-icon hs-ui-icon_down", viewBox: "0 0 1024 1024", version: "1.1", xmlns: "http://www.w3.org/2000/svg", "p-id": "8693", width: "16", height: "16", children: /* @__PURE__ */ e("path", { d: "M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3 0.1-12.7-6.4-12.7z", "p-id": "8694", fill: "#696868" }) }), U = ({ data: i }) => /* @__PURE__ */ e(
  "div",
  {
    className: "hs-ui-icon",
    dangerouslySetInnerHTML: { __html: i }
  }
), Y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  CloseIcon: B,
  DownIcon: z,
  LeftIcon: j,
  LoginOut: F,
  RightIcon: X,
  SearchIcon: W,
  UploadIcon: R,
  default: U
}, Symbol.toStringTag, { value: "Module" }));
console.log("icon", Y);
const A = (i) => {
  const {
    list: n = [],
    className: t = "",
    itemLayout: s = "vertical",
    header: o,
    footer: l,
    // bordered = false,
    children: c,
    renderItem: d = () => /* @__PURE__ */ e(b, {}),
    loading: r = !1
  } = i, m = /* @__PURE__ */ e("div", { className: "hs-ui-list_loading", children: "加载中..." }), p = /* @__PURE__ */ e("div", { className: "hs-ui-list_no-data", children: "暂无数据" }), _ = n.map((h, a) => d(h, a)), v = r ? m : !c && n && n.length > 0 ? _ : p;
  return /* @__PURE__ */ u("div", { className: `hs-ui-list ${t}`, children: [
    o && /* @__PURE__ */ e("div", { className: "hs-ui-list_header", children: o }),
    /* @__PURE__ */ u("div", { className: `hs-ui-list_wrapper hs-ui-list_wrapper-${s ?? "horizontal"}`, children: [
      v,
      c
    ] }),
    l && /* @__PURE__ */ e("div", { className: "hs-ui-list_footer", children: l })
  ] });
}, q = (i) => {
  const { className: n, bordered: t = !1, children: s } = i;
  return /* @__PURE__ */ e(
    "div",
    {
      className: `hs-ui-list_item ${n ?? ""} hs-ui-list_item${t ? "-bordered" : ""}`,
      children: s || /* @__PURE__ */ e(b, {})
    }
  );
}, G = A;
G.Item = q;
const M = (i) => {
  const {
    open: n,
    title: t = "modal title",
    header: s,
    closeIcon: o,
    footer: l,
    children: c,
    canceltext: d = "取消",
    okText: r = "确认",
    isShowOkBtn: m = !0,
    isShowCancelBtn: p = !0,
    maskClosable: _ = !1,
    isShowCloseIcon: v = !0,
    closeByESC: h = !1,
    onOk: a,
    onCancel: g,
    onClose: f
  } = i, w = k(null), P = () => {
    w.current && (w.current.style.display = "none");
  }, O = () => {
    w.current && (w.current.style.display = "flex");
  }, E = (x) => {
    P(), g && g(x);
  }, I = (x) => {
    var L;
    x.key === "Escape" && ((L = w.current) == null || L.click());
  };
  return C(() => (n ? O() : P(), h && window.addEventListener("keydown", I), () => {
    h && window.removeEventListener("keydown", I);
  }), [n]), /* @__PURE__ */ e(
    "div",
    {
      ref: w,
      className: "hs-ui-modal-mask",
      onClick: _ ? E : () => {
      },
      children: /* @__PURE__ */ e(
        "div",
        {
          className: "hs-ui-modal",
          onClick: (x) => x.stopPropagation(),
          children: /* @__PURE__ */ u("div", { className: "hs-ui-modal-wrapper", children: [
            /* @__PURE__ */ u("div", { className: "hs-ui-modal__header", children: [
              /* @__PURE__ */ e("div", { className: "hs-ui-modal__header-title", children: s ?? t }),
              v && /* @__PURE__ */ e("div", { className: "hs-ui-modal__close", children: o ?? /* @__PURE__ */ e(N, { onClick: f ?? g, children: /* @__PURE__ */ e(B, {}) }) })
            ] }),
            /* @__PURE__ */ e("div", { className: "hs-ui-modal__body", children: c ?? /* @__PURE__ */ e("div", { children: "modal body" }) }),
            /* @__PURE__ */ e("div", { className: "hs-ui-modal__footer", children: l ?? /* @__PURE__ */ u(b, { children: [
              m && /* @__PURE__ */ e(
                N,
                {
                  type: "success",
                  size: "medium",
                  className: "hs-ui-modal__footer-cancel",
                  onClick: g,
                  children: d
                }
              ),
              p && /* @__PURE__ */ e(
                N,
                {
                  type: "success",
                  size: "medium",
                  className: "hs-ui-modal__footer-ok",
                  onClick: a,
                  children: r
                }
              )
            ] }) })
          ] })
        }
      )
    }
  );
}, te = (i) => {
  const { open: n, appendToBody: t = !0, destroyOnClose: s = !0 } = i, [o, l] = y();
  let c = null;
  return C(() => (n ? t && (c = document.createElement("div"), document.body.appendChild(c), l(c)) : s && c && (document.body.removeChild(c), l(null)), () => {
    c && document.body.removeChild(c);
  }), [n]), t ? o && S.createPortal(/* @__PURE__ */ e(M, { ...i }), o) : /* @__PURE__ */ e(M, { ...i });
}, oe = (i) => {
  const {
    pages: n,
    currentPage: t,
    setCurrentPage: s,
    totalLength: o,
    buttonSelectType: l = "selected",
    buttonType: c = "primary",
    buttonShape: d,
    preButton: r = /* @__PURE__ */ e("span", { children: "PRE" }),
    nextButton: m = /* @__PURE__ */ e("span", { children: "NEXT" })
  } = i, p = [...Array(n).keys()], _ = (a) => {
    s(a);
  }, v = () => {
    const a = t - 1;
    a > 0 && s(a);
  }, h = () => {
    t + 1 <= o && s(t + 1);
  };
  return /* @__PURE__ */ e("div", { className: "hs-ui-pagniation", children: /* @__PURE__ */ u("ul", { className: "hs-ui-pagniation__list", children: [
    /* @__PURE__ */ e(
      "li",
      {
        className: "hs-ui-pagniation__item hs-ui-pagniation__pre-item",
        onClick: v,
        children: /* @__PURE__ */ e(
          N,
          {
            type: c,
            shape: d,
            className: "hs-ui-pagniation__button",
            children: r
          }
        )
      }
    ),
    p.map((a) => /* @__PURE__ */ e(
      "li",
      {
        className: `hs-ui-pagniation__item ${t === a + 1 ? "hs-ui-pagniation__item-selected" : ""}`,
        onClick: () => _(a + 1),
        children: /* @__PURE__ */ e(
          N,
          {
            type: t === a + 1 ? l : c,
            shape: d,
            className: "hs-ui-pagniation__button",
            children: a + 1
          }
        )
      },
      a
    )),
    /* @__PURE__ */ e(
      "li",
      {
        className: "hs-ui-pagniation__item hs-ui-pagniation__next-item",
        onClick: h,
        children: /* @__PURE__ */ e(
          N,
          {
            type: c,
            shape: d,
            className: "hs-ui-pagniation__button",
            children: m
          }
        )
      }
    )
  ] }) });
}, J = (i = null) => ({ width: (i == null ? void 0 : i.offsetWidth) ?? 0, height: (i == null ? void 0 : i.offsetHeight) ?? 0 }), K = (i = null) => {
  const {
    bottom: n = 0,
    height: t = 0,
    left: s = 0,
    right: o = 0,
    top: l = 0,
    width: c = 0,
    x: d = 0,
    y: r = 0
  } = (i == null ? void 0 : i.getBoundingClientRect()) ?? {};
  return {
    bottom: n,
    height: t,
    left: s,
    right: o,
    top: l,
    width: c,
    x: d,
    y: r
  };
}, $ = (i) => {
  var h;
  const { children: n = "", className: t = "", wrapperRef: s = null } = i, o = k(null);
  let l = {
    root: document.body,
    rootMargin: "0px",
    threshold: 1
  };
  const c = (a) => {
    a.forEach((g) => {
      console.log("entry", g);
    });
  };
  new IntersectionObserver(c, l).observe(s == null ? void 0 : s.current);
  const [r, m] = y(0), [p, _] = y(0), v = () => {
    const { width: a, height: g } = J(s == null ? void 0 : s.current), { x: f, y: w } = K(s == null ? void 0 : s.current);
    m(f), _(w), console.log("wrapperX", r, "wrapperY", p), o.current && (o.current.style.inset = `${g + w}px 0 0 ${f}px `, o.current.style.width = `${a}px`);
  };
  return C(() => {
    console.log("wrapperRef", s), v();
  }, [(h = s == null ? void 0 : s.current) == null ? void 0 : h.getBoundingClientRect()]), C(() => {
    console.log("wrapperX");
  }, [r, p]), /* @__PURE__ */ e(
    "div",
    {
      ref: o,
      className: `hs-ui-popper ${t}`,
      children: /* @__PURE__ */ e("div", { className: "hs-ui-popper__wrapper", children: /* @__PURE__ */ e("div", { className: "hs-ui-popper__content", children: n }) })
    }
  );
}, Q = (i) => {
  const { open: n, appendToBody: t = !0 } = i, [s, o] = y(null);
  return C(() => {
    if (n) {
      const l = document.createElement("div");
      document.body.appendChild(l), o(l);
    } else
      s && (document.body.removeChild(s), o(null));
  }, [n]), t ? s && S.createPortal(/* @__PURE__ */ e($, { ...i }), s) : n && /* @__PURE__ */ e($, { ...i });
}, Z = (i) => {
  const {
    options: n = [],
    value: t = "value",
    label: s = "label",
    children: o = "",
    onChange: l = () => {
    }
  } = i;
  return /* @__PURE__ */ e("div", { className: "hs-ui-select__dropdown", children: /* @__PURE__ */ u("div", { className: "hs-ui-select__dropdown-wrapper", children: [
    /* @__PURE__ */ e("div", { className: "hs-ui-select__dropdown-arrow" }),
    /* @__PURE__ */ e("ul", { className: "hs-ui-select__dropdown-list", children: o || n && n.length > 0 && n.map((c, d) => /* @__PURE__ */ e(
      "li",
      {
        className: "hs-ui-select__list-item",
        onClick: (r) => {
          r.stopPropagation(), console.log("onClick"), l(c[t], t, c, r);
        },
        value: c[t],
        children: c[s]
      },
      d
    )) })
  ] }) });
}, ce = (i) => {
  const {
    popperClassName: n = "",
    className: t = "",
    options: s = [],
    value: o = "value",
    label: l = "label",
    inputConfig: c = {},
    showSearch: d = !1,
    prefix: r = /* @__PURE__ */ e(b, {}),
    suffix: m = /* @__PURE__ */ e(b, {}),
    onChange: p
  } = i, [_, v] = y(!1), h = k(null), a = k(null), g = () => {
    console.log("openDropdown"), a.current && (a.current.style.display = "block", v(!0));
  }, f = () => {
    console.log("hiddenDropdown"), a.current;
  };
  return /* @__PURE__ */ u("div", { className: `hs-ui-select ${t}`, children: [
    /* @__PURE__ */ u(
      "div",
      {
        ref: h,
        className: "hs-ui-select__wrapper",
        onFocus: g,
        onBlur: f,
        children: [
          /* @__PURE__ */ e("div", { className: "hs-ui-select__prefix", children: r }),
          /* @__PURE__ */ e(
            D,
            {
              value: o,
              suffix: /* @__PURE__ */ e(z, {}),
              readOnly: !d,
              ...c
            }
          ),
          /* @__PURE__ */ e("div", { className: "hs-ui-select__suffix", children: m })
        ]
      }
    ),
    /* @__PURE__ */ e(
      "div",
      {
        ref: a,
        className: "hs-ui-select__dropdown",
        style: { width: "100%" },
        children: /* @__PURE__ */ e(
          Q,
          {
            className: n,
            wrapperRef: h,
            open: _,
            children: /* @__PURE__ */ e(
              Z,
              {
                options: s,
                value: o,
                label: l,
                onChange: p
              }
            )
          }
        )
      }
    )
  ] });
};
export {
  N as Button,
  ne as Container,
  H as Form,
  Y as Icon,
  D as Input,
  G as List,
  te as Modal,
  oe as Pagniation,
  Q as Popper,
  ce as Select
};
